package com.haixiaoke.saas.enterprise.lock.controller;


import com.haixiaoke.saas.common.annotation.TenantScope;
import com.haixiaoke.saas.common.core.domain.AjaxResult;
import com.haixiaoke.saas.common.core.page.TableDataInfo;
import com.haixiaoke.saas.lock.domain.HouseLockSetting;
import com.haixiaoke.saas.lock.service.IHouseLockSettingService;
import com.haixiaoke.saas.system.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static com.haixiaoke.saas.common.tenant.TenantContext.getTenantId;


/**
 * 锁设置Controller
 *
 * @author qixi
 * @date 2024-07-25
 */
@RestController
@RequestMapping("/enterprise/lock/lockSetting")
public class EnterpriseHouseLockSettingController extends BaseController {
    @Autowired
    private IHouseLockSettingService houseLockSettingService;

    /**
     * 查询锁设置列表
     */
    @PreAuthorize("@ss.hasPermi('lock:lockSetting:list')")
    @GetMapping("/list")
    @TenantScope
    public TableDataInfo list(HouseLockSetting houseLockSetting) {
        houseLockSetting.setTenantId(getTenantId());
        List<HouseLockSetting> list = houseLockSettingService.selectHouseLockSettingList(houseLockSetting);
        return getDataTable(list);
    }

    /**
     * 修改锁设置
     */
    @PutMapping
    public AjaxResult edit(@RequestBody HouseLockSetting houseLockSetting) {
        return toAjax(houseLockSettingService.updateHouseLockSetting(houseLockSetting));
    }


}
